# _*_coding:utf-8_*_
# 作者    ：SunDuWei
# 创作时间 ：2020-02-18
import json
config_io = r'E:\课堂资料\future\config.json'
data_io = r'E:\课堂资料\future_data\%s_all_%s_data%s.xlsx'
kind = 'RB'
kind_min = 'min15'
day_main_io = data_io % (kind, 'day', '')
day_second_io = data_io % (kind, 'day', '_second')
day_min_io = data_io % (kind, kind_min, '')

# 创建jsontext
jsontext = {
    'basicinfo': {},
    'data_io': data_io,
    'x1_param': {},
    'y1_param': {}
            }

# 基础信息
basicinfo = {
        'kind': kind,
        'kind_min': kind_min
    }

x1_param = {
    'macd_param': {},
    'kdj_param': {},
    'rsi_param': {},
    'boll_param': {}
           }
jsontext['basicinfo'] = basicinfo
jsontext['x1_param'] = x1_param

# x1类指标因子参数
macd_param = {
    'param_fast': 12,
    'param_slow': 26,
    'param_ema': 9
}
jsontext['x1_param']['macd_param'] = macd_param

kdj_param = {
        'param_fastk': 9,
        'param_slowk': 3,
        'param_slowk_ma': 0,
        'param_slowd': 3,
        'param_slowd_ma': 0
    }
jsontext['x1_param']['kdj_param'] = kdj_param

rsi_param = {
        'param_rs': 12
    }
jsontext['x1_param']['rsi_param'] = rsi_param

boll_param = {
        'param_ma': 20,
        'param_stdup': 2,
        'param_stddown': 2
    }
jsontext['x1_param']['boll_param'] = boll_param

#y1类指标
y1_param = {
    'y1_param_day': {},
    'y1_param_min': {}
           }
y1_param_day = {
    'day_param1': 1, 'day_param2': 3, 'day_param3': 5,
    'day_param4': 12, 'day_param5': 26,
                }
y1_param_min = {
    'nmin': 15,
    'min_param1': 30, 'min_param2': 60, 'min_param3': 120,
    'min_param4': 180, 'min_param5': 240,
    'min_param6': 'close_yield'
}
jsontext['y1_param'] = y1_param
jsontext['y1_param']['y1_param_day'] = y1_param_day
jsontext['y1_param']['y1_param_min'] = y1_param_min
# 生成json文件
jsondata = json.dumps(jsontext, indent=4, separators=(',', ': '), ensure_ascii=False)
f = open(config_io, 'w')
f.write(jsondata)
f.close()
